package com.ljx.threadTest.threadEnum;


/**
 * @author 李加喜
 * @Package com.ljx.threadTest.config
 * @date 2024-05-29 10:13
 */
public enum CommonErrorCode implements ErrorCode {
    /**
     *
     */
    REQUEST_PARAM_ERROR(400, "请求参数不符合"),
    UNAUTHORIZED(40101, "身份验证无效，请登录"),
    LOGIN_TOKEN_IS_UPDATE(40102, "您的账号在其他地方被登录，请重新登录"),
    LOGIN_STATUS_EXPIRE(40103, "身份验证过期，请重新登录"),
    LOGIN_TOKEN_IS_NULL(40104, "登录令牌为空，请登录"),
    FORBIDDEN(403, "权限不够"),
    NOT_FOUND(404, "资源信息不存在"),
    METHOD_NOT_SUPPORTED(405, "请求方法错误"),
    FILE_OVER_SIZE(413, "上传文件大小超出限制"),
    RESOURCE_LOCKED(423, "资源被锁定，请稍后再试"),
    SERVER_LIMIT_CODE(429, "服务限流"),
    SYSTEM_ERROR(500, "服务器异常"),
    SERVER_DOWNGRADE_CODE(700, "服务降级"),
    ;


    /**
     * 应用编码
     */
    private int app;

    /**
     * 模块编码
     */
    private int module;

    /**
     * 错误码
     */
    private final int code;

    /**
     * 错误信息
     */
    private final String name;


    @Override
    public int getApp() {
        return getRealApp(app);
    }

    @Override
    public int getModule() {
        return getRealModule(module);
    }

    @Override
    public int getCode() {
        return code;
    }

    @Override
    public String getName() {
        return name;
    }

    CommonErrorCode(int code, String name) {
        this.code = code;
        this.name = name;
        check();
    }

    CommonErrorCode(int module, int code, String name) {
        this.module = module;
        this.code = code;
        this.name = name;
        check();
    }

    CommonErrorCode(int app, int module, int code, String name) {
        this.app = app;
        this.module = module;
        this.code = code;
        this.name = name;
        check();
    }
}
